package com.wclass.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.wclass.entity.BaseRecruitment;
import com.wclass.entity.BaseRecruitmentType;
import com.wclass.mapper.BaseRecruitmentMapper;
import com.wclass.mapper.BaseRecruitmentTypeMapper;
import com.wclass.service.IBaseRecruitmentTypeService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 人才招聘类型 服务实现类
 * </p>
 *
 * @author SEN
 * @since 2019-02-13
 */
@Service
public class BaseRecruitmentTypeServiceImpl extends ServiceImpl<BaseRecruitmentTypeMapper, BaseRecruitmentType> implements IBaseRecruitmentTypeService {

    @Autowired
    private BaseRecruitmentMapper recruitmentMapper;

    @Override
    public List<BaseRecruitmentType> findCountList() {

        List<BaseRecruitmentType> list = baseMapper.selectList(null);
        for (BaseRecruitmentType info : list) {
            info.setCount(recruitmentMapper.selectCount(new EntityWrapper<BaseRecruitment>().eq("type_id", info.getId())));
        }
        BaseRecruitmentType type = new BaseRecruitmentType();
        type.setId(0L);
        type.setName("全部");
        type.setCrtTime(new Date());
        type.setCount(recruitmentMapper.selectCount(null));

        list.add(type);
        return list;
    }
}
